package com.mentaleye.dal.dao.mybatis;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mentaleye.dal.dao.RoleDao;
import com.mentaleye.dal.model.Role;
import com.mentaleye.dal.model.RoleExample;
import com.mentaleye.dal.service.RoleMapper;
@Repository
public class RoleDaoImpl extends BaseDao implements RoleDao {

	@Autowired
	private RoleMapper roleMapper;
	@Override
	public boolean addRole(Role role) {
		return getResultByInt(roleMapper.insertSelective(role));
	}

	@Override
	public boolean updateRole(Role role) {
		return getResultByInt(roleMapper.updateByPrimaryKeySelective(role));
	}

	@Override
	public boolean deleteRole(Integer ids) {
		RoleExample roleExample = new RoleExample();
		roleExample.createCriteria().andRoleNoEqualTo(ids);
		return getResultByInt(roleMapper.deleteByExample(roleExample));
	}

	@Override
	public List<Role> selectRoleList(RoleExample roleExample) {
		return roleMapper.selectByExample(roleExample);
	}

	@Override
	public List<Role> selectRole(Map<String, Object> map) {
		return roleMapper.selectByMap(map);
	}

	@Override
	public Role selectRoleByNo(Integer roleNo) {
		return roleMapper.selectByPrimaryKey(roleNo);
	}

}
